package com.doone.telmarket.infrastructure.dao.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.doone.telmarket.domain.Activity;
import com.doone.telmarket.domain.ActivityOrder;
import com.doone.telmarket.infrastructure.dao.ActivityDAO;
import com.doone.telmarket.infrastructure.dao.BaseDaoSupport;

/**
 * @package com.doone.telmarket.infrastructure.dao.impl
 * @author 甘雨波
 * @description 精彩促销推荐DAO实现
 * @date 2009-10-26
 */
@Service("activityDAO")
public class ActivityDaoImpl extends BaseDaoSupport implements ActivityDAO {

	/* (non-Javadoc)查询所有
	 * @see com.doone.telmarket.infrastructure.dao.ActivityDAO#selectActivity()
	 */
	@SuppressWarnings("unchecked")
	public List<Activity> selectActivity() {

		return getSqlMapClientTemplate().queryForList("Activity.selectActivity");
	}

	/* (non-Javadoc)更新
	 * @see com.doone.telmarket.infrastructure.dao.ActivityDAO#updateActivity(com.doone.telmarket.domain.Activity)
	 */
	public void updateActivity(Activity activity) {
		getSqlMapClientTemplate().update("Activity.updateActivity", activity);
	}

	public void deleteActivity(int activityid) {
		getSqlMapClientTemplate().delete("Activity.deleteActivity",activityid);
		
	}

	public void saveActivity(Activity activity) {
		
//		System.out.println("DAO======================================================="+activity.getBigImage());
//		System.out.println("DAO======================================================="+activity.getImagePath());
//		System.out.println("DAO======================================================="+activity.getTitle());
//		System.out.println("DAO======================================================="+activity.getContent());
//		System.out.println("DAO======================================================="+activity.getPerson());
//		System.out.println("DAO======================================================="+activity.getBegin());
//		System.out.println("DAO======================================================="+activity.getEnd());
//		System.out.println("DAO======================================================="+activity.getUrl());
		getSqlMapClientTemplate().insert("Activity.insertActivity",activity);
	}

	public Activity selectById(int id) {
		return (Activity)getSqlMapClientTemplate().queryForObject("Activity.selectByPrimaryKey", id);
	}

	public void deleteActivityOrder() {
		getSqlMapClientTemplate().delete("Activity.deleteActivityOrder");
	}

	public void insertActivityOrder(ActivityOrder a) {
		getSqlMapClientTemplate().insert("Activity.insertActivityOrder",a);
	}

	public List<Activity> selectActivityOrder() {
		return getSqlMapClientTemplate().queryForList("Activity.selectActivityOrder");
	}

}
